<template>
	<view class="login">
		 <form @submit="formSubmit">
  

            <view class="section">
                <view class="iconfont icon-shoujihao"></view>
                <input name="account" placeholder="请输入手机号" />
            </view>
			
			<view class="section">
				<view class="iconfont icon-mima"></view>
				<input name="password" placeholder="请输入密码"  password="true" />
			</view>

            <view class="btn-area">
                <button formType="submit">登 录</button>
              
			   
            </view>
			
			<view class="to">
				<navigator url="register">注 册</navigator>
			</view>
        </form>
	</view>
</template>

<script>
	import base from '../../common/base.js';
	export default {
		data() {
			return {
				
			};
		}, 
		methods:{
			formSubmit: function (e) {

				var formData = e.detail.value;
				
				if(formData.account == '') {
					base.base.alert('请输入手机号'); return false;
				}
				
				if(formData.password == '') {
					base.base.alert('请输入密码'); return false;
				}
				
				var that = this;
				var nui = nui;
				base.base.request({
					data: formData,
					url: 'user/login',
					login: false,
					sCallback: function(res){
						if(res.code == 200){
							var userinfo = res.data.userinfo;
							var token = userinfo.token;
							
							uni.setStorageSync('userinfo', userinfo);
							uni.setStorageSync('token', token);
							uni.reLaunch({
								url: '/pages/index/index'
							})
						}
					}
				});
				
			}
		}
	}
</script>

<style>
	
	.login{
		width: 100%;
	}
	form{
		padding: 40upx;
		flex: 1;
	}
	
	.section{
		border-bottom: 1upx solid #eee;
		line-height: 80upx;
		font-size: 24upx;;
	}
	
	.section .iconfont{
		font-size: 32upx;;
	}
	
	.section input{
		flex: 1;
		height: 80upx;
		line-height: 80upx;
		padding: 0 30upx;
	}
	
	.btn-area{
		margin-top: 40upx;
	}
	button{
		width: 100%;
		background: linear-gradient(143deg,rgba(129,95,250,1) 0%,rgba(78,106,240,1) 100%);
		color: #fff;
	}
	
	.to{
		text-align: center;
		font-size: 28upx;
		margin-top: 40upx;
	}
	
	.to navigator{
		width: 100%;
	}
</style>